		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='templates/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="templates/js/bootstrap.min.js"></script>
		<script src="templates/js/bootstrap-datepicker.min.js"></script>
		<script src="templates/js/jquery.mask.min.js"></script>
		<script src="templates/js/jquery.ui.touch-punch.min.js"></script>
		<script src="templates/js/fullcalendar.min.js"></script>
		<script src="templates/js/bootbox.min.js"></script>
		<script src="templates/js/ace-elements.min.js"></script>
		<script src="templates/js/ace.min.js"></script>
		<script type="text/javascript">
		{literal}
			function show_box(id) {
			 jQuery('.widget-box.visible').removeClass('visible');
			 jQuery('#'+id).addClass('visible');
			}
			$('.money').mask('000,000,000,000,000', {reverse: true});
		{/literal}
		</script>
		<script type="text/javascript">
			jQuery(function($) {
				$(window).load(function() {
					$(".loader").fadeOut('slow');
				});
		{if $menu != 'main'}
				$.ajaxSetup({
					beforeSend: function(){
						$('.progressbar').show();
					},
					success: function(){
						$('.progressbar').hide();
					}
				});
		{/if}
		
		{if $menu == 'main'}
			{section name=event_today loop=$event_today}
				$('#done_{$event_today[event_today][0]}').click(function(){
					$.ajax({
						url: 'ajax?get=event&do=done',
						data: 'id={$event_today[event_today][0]}',
						type: "POST",
						success: function(json) {
							$("li").addClass("selected");
						}
					});
				});
				
				$('#del_{$event_today[event_today][0]}').click(function(){
					$.ajax({
						url: 'ajax?get=event&do=delete',
						data: 'id={$event_today[event_today][0]}',
						type: "POST",
						success: function(json) {
							$("li#{$event_today[event_today][0]}").remove();
						}
					});
				});
			{/section}
			
			{literal}
				$('#external-events div.external-event').each(function() {
					var eventObject = {
						title: $.trim($(this).text()) // use the element's text as the event title
					};
					$(this).data('eventObject', eventObject);
					$(this).draggable({
						zIndex: 999,
						revert: true,      // will cause the event to go back to its
						revertDuration: 0  //  original position after the drag
					});
				});
				var date = new Date();
				var d = date.getDate();
				var m = date.getMonth();
				var y = date.getFullYear();
				var calendar = $('#calendar').fullCalendar({
					 buttonText: {
						prev: '<i class="icon-chevron-left"></i>',
						next: '<i class="icon-chevron-right"></i>'
					},
					header: {
						left: 'prev,next today',
						center: 'title',
						right: 'month,agendaWeek,agendaDay'
					},
					events: "ajax?get=event&do=list",
					editable: true,
					droppable: true, // this allows things to be dropped onto the calendar !!!
					selectable: true,
					selectHelper: true,
					select: function(start, end, allDay) {
						bootbox.prompt("Công việc mới:", function(title) {
							if (title !== null) {
								start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
								end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
								$.ajax({
									url: 'ajax?get=event&do=add',
									data: 'title='+title+'&start='+start+'&end='+end,
									type: "POST"
								});
								calendar.fullCalendar('renderEvent',
									{
										title: title,
										start: start,
										end: end,
										allDay: allDay
									},
									true // make the event "stick"
								);
							}
						});
						calendar.fullCalendar('unselect');
					},
					drop: function(date, allDay) { // this function is called when something is dropped
						var originalEventObject = $(this).data('eventObject');
						var $extraEventClass = $(this).attr('data-class');
						var copiedEventObject = $.extend({}, originalEventObject);
						copiedEventObject.start = date;
						copiedEventObject.allDay = allDay;
						start = $.fullCalendar.formatDate(copiedEventObject.start, "yyyy-MM-dd HH:mm:ss");
						if($extraEventClass) copiedEventObject['className'] = [$extraEventClass];
						$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
						$.ajax({
							url: 'ajax?get=event&do=add',
							data: 'title='+copiedEventObject.title+'&start='+start+'&end='+start+'&className='+$extraEventClass ,
							type: "POST"
						});
						if ($('#drop-remove').is(':checked')) {
							// if so, remove the element from the "Draggable Events" list
							$(this).remove();
							
						}
					},
					eventClick: function(calEvent, jsEvent, view) {
						var form = $("<form class='form-inline'><label> Thay đổi công việc: </label></form>");
						form.append("<input class='middle' autocomplete=off type=text value='"+calEvent.title+"' /> ");
						form.append("<button type='submit' class='btn btn-sm btn-success'><i class='icon-ok'></i> Lưu</button>");
						var div = bootbox.dialog({
							message: form,
							buttons: {
								"delete" : {
									"label" : "<i class='icon-trash'></i> Xóa công việc",
									"className" : "btn-sm btn-danger",
									"callback": function() {
										calendar.fullCalendar('removeEvents' , function(ev){
											$.ajax({
												url: 'ajax?get=event&do=delete',
												data: 'id='+calEvent.id,
												type: "POST"
											});
											return (ev._id == calEvent._id);
										})
									}
								} ,
								"close" : {
									"label" : "<i class='icon-remove'></i> Đóng",
									"className" : "btn-sm"
								} 
							}
						});
						form.on('submit', function(){
							calEvent.title = form.find("input[type=text]").val();
							calendar.fullCalendar('updateEvent', calEvent);
							$.ajax({
								url: 'ajax?get=event&do=update',
								data: 'title='+calEvent.title+'&id='+calEvent.id,
								type: "POST"
							});
							div.modal("hide");
							return false;
						});
					},
					eventDrop: function(event, dayDelta, minuteDelta, allDay) {
						start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
						end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
						$.ajax({
							url: 'ajax?get=event&do=update',
							data: 'title='+event.title+'&start='+start+'&end='+end+'&allDay='+allDay+'&id='+event.id,
							type: "POST"
						});
					},
					eventResize: function(event) {
						start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
						end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
						$.ajax({
							url: 'ajax?get=event&do=update',
							data: 'title='+event.title+'&start='+start+'&end='+end+'&id='+event.id,
							type: "POST"
						});

					}
				});
				$('#recent-box [data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('.tab-content')
					var off1 = $parent.offset();
					var w1 = $parent.width();
					var off2 = $source.offset();
					var w2 = $source.width();
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}

				var agent = navigator.userAgent.toLowerCase();
				if("ontouchstart" in document && /applewebkit/.test(agent) && /android/.test(agent))
				  $('#tasks').on('touchstart', function(e){
					var li = $(e.target).closest('#tasks li');
					if(li.length == 0)return;
					var label = li.find('label.inline').get(0);
					if(label == e.target || $.contains(label, e.target)) e.stopImmediatePropagation() ;
				});
			
				$('#tasks').sortable({
					opacity:0.8,
					revert:true,
					forceHelperSize:true,
					placeholder: 'draggable-placeholder',
					forcePlaceholderSize:true,
					tolerance:'pointer',
					stop: function( event, ui ) {//just for Chrome!!!! so that dropdowns on items don't appear below other items after being moved
						$(ui.item).css('z-index', 'auto');
					}
					}
				);
				$('#tasks').disableSelection();
				$('#tasks input:checkbox').removeAttr('checked').on('click', function(){
					if(this.checked) $(this).closest('li').addClass('selected');
					else $(this).closest('li').removeClass('selected');
				});
		{/literal}
		{/if}
	
		{if $menu == 'contract_list'}
			{section name=contract loop=$contract}
				$("#view_{$contract[contract][0]}").click(function(){
					$("#dialog_view_{$contract[contract][0]}").dialog({literal}{width: '80%', modal: true}{/literal});
				});
				
				$("#nview_{$contract[contract][0]}").click(function(){
					$("#dialog_view_{$contract[contract][0]}").dialog({literal}{width: '80%', modal: true}{/literal});
				});
				
				$("#dialog_view_{$contract[contract][0]}").on( "dialogclose", function( event, ui ){
					$("#display_status1_{$contract[contract][0]}").load('ajax?get=contract&do=status&id={$contract[contract][0]}&display=1').hide().fadeIn("slow");
				});
				
				$("#edit_{$contract[contract][0]}").click(function(){
					$("#dialog_edit_{$contract[contract][0]}").dialog({literal}{width: '95%', modal: true}{/literal});
				});
				
				$("#close_{$contract[contract][0]}").click(function(){
					$("#dialog_edit_{$contract[contract][0]}").dialog("close");
				});

				$("#delete_{$contract[contract][0]}").on(ace.click_event, function() {
					bootbox.confirm("Có chắc chắn?", function(result) {
						if(result) {
							$.ajax({
								url: 'ajax?get=contract&do=delete',
								data: 'id={$contract[contract][0]}',
								type: "POST",
								success: function(json) {
									$("#contract").load('contract?do=list&page={$contract_page_curr}&get=table').hide().fadeIn("slow");
								}
							});
						}
					});
				});
				
				var datebb_{$contract[contract][0]} = $('#datebb_{$contract[contract][0]}').datepicker({literal}{autoclose:true}{/literal});
				datebb_{$contract[contract][0]}.on('changeDate', function(ev){
					$.ajax({
						url: 'ajax?get=contract&do=datebb',
						data: 'id={$contract[contract][0]}&value='+ev.date.valueOf(),
						type: "POST"
					});
				});
				datebb_{$contract[contract][0]}.next().on(ace.click_event, function(){
					$(this).prev().focus();
				});
				
				$('#date_{$contract[contract][0]}').datepicker({literal}{autoclose:true}{/literal}).next().on(ace.click_event, function(){
					$(this).prev().focus();
				});

				var count_{$contract[contract][0]} = {$contract[contract][11]};
				$('#addmore_{$contract[contract][0]}').click(function(){
					count_{$contract[contract][0]}++;
					var clonedRow_{$contract[contract][0]} = '		<td align="center"><b>'+count_{$contract[contract][0]}+'</b></td>';
					clonedRow_{$contract[contract][0]} += '			<td align="left">';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">';
					clonedRow_{$contract[contract][0]} += '					Sản phẩm: <input id="product_name_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="product_name[]" value="" size="35">';
					clonedRow_{$contract[contract][0]} += '					<select name="product_page[]">{for $foo=1 to 10}<option value="{$foo}">{$foo}</option>{/for}</select> liên';
					clonedRow_{$contract[contract][0]} += '				</span><br>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Mẫu số: <input id="form_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="form[]" value="" size="15"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Ký hiệu: <input id="serial_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="serial[]" value="" size="15"></span><br>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Logo: <label id="logo_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="logo[]" id="logo_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" /> <span class="lbl"></span></label><input type="hidden" id="logo_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" name="logo[]" value="0" /></span>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Hoa văn: <label id="hoavan_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="hoavan[]" id="hoavan_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" /> <span class="lbl"></span></label><input type="hidden" id="hoavan_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" name="hoavan[]" value="0" /></span>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Chống ký: <label id="signed_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="signed[]" id="signed_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" /> <span class="lbl"></span></label><input type="hidden" id="signed_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" name="signed[]" value="0" /></span>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Mật mã: <label id="matma_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="matma[]" id="matma_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" /> <span class="lbl"></span></label><input type="hidden" id="matma_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" name="matma[]" value="0" /></span>';
					clonedRow_{$contract[contract][0]} += '			</td>';
					clonedRow_{$contract[contract][0]} += '			<td align="left">';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Số màu: <select name="color[]">{for $foo=1 to 10}<option value="{$foo}">{$foo}</option>{/for}</select> màu</span><br>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Ruột:<select name="bowel[]"><option value="baibang">Bãi Bằng</option><option value="cacbon">Cacbon</option><option value="offset">Offset</option></select></span><br>';
					clonedRow_{$contract[contract][0]} += '				<span class="inline">Kích thước: <input type="text" name="size[]" value="" size="10"></span>';
					clonedRow_{$contract[contract][0]} += '			</td>';
					clonedRow_{$contract[contract][0]} += '			<td align="center">';
					clonedRow_{$contract[contract][0]} += '				<select name="unit[]"><option value="quyen50">Quyển(50 số)</option><option value="quyen100">Quyển(100 số)</option><option value="so">Số</option><option value="thung">Thùng</option><option value="to">Tờ</option></select>';
					clonedRow_{$contract[contract][0]} += '			</td>';
					clonedRow_{$contract[contract][0]} += '			<td align="center"><input style="text-align:right" id="quantity_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="quantity[]" class="money" value="" size="5"></td>';
					clonedRow_{$contract[contract][0]} += '			<td align="center"><input style="text-align:right" id="quantity_t_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="quantity_t[]" value="" size="5"></td>';
					clonedRow_{$contract[contract][0]} += '			<td align="center"><input style="text-align:right" id="quantity_d_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="quantity_d[]" value="" size="5"></td>';
					clonedRow_{$contract[contract][0]} += '			<td align="right"><input style="text-align:right" id="price_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="text" name="price[]" class="money" value="" size="10"></td>';
					var appendRow_{$contract[contract][0]} = '<tr id="tr_{$contract[contract][0]}">' + clonedRow_{$contract[contract][0]} + '</tr>';
					$('#addtable_{$contract[contract][0]} tr:last').after(appendRow_{$contract[contract][0]});

					$('#logo_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').change(function(){
						if($(this).prop('checked')){
							$('#logo_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').remove();
						}
						else{
							$('#logo_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').after('<input id="logo_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="hidden" name="logo[]" value="0">');
						}
					});
					$('#hoavan_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').change(function(){
						if($(this).prop('checked')){
							$('#hoavan_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').remove();
						}
						else{
							$('#hoavan_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').after('<input id="hoavan_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="hidden" name="hoavan[]" value="0">');
						}
					});
					$('#signed_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').change(function(){
						if($(this).prop('checked')){
							$('#signed_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').remove();
						}
						else{
							$('#signed_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').after('<input id="signed_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="hidden" name="signed[]" value="0">');
						}
					});
					$('#matma_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').change(function(){
						if($(this).prop('checked')){
							$('#matma_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').remove();
						}
						else{
							$('#matma_lbl_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}').after('<input id="matma_hidden_'+count_{$contract[contract][0]}+'_{$contract[contract][0]}" type="hidden" name="matma[]" value="0">');
						}
					});
				});
				
				$("#submit_edit_{$contract[contract][0]}").click(function(){
					var content;
					$("input").removeClass('input-error');
					$("#form_edit_{$contract[contract][0]}").submit(function(){
						var postData = $(this).serializeArray();
						$.ajax({
							url: 'ajax?get=contract&do=update',
							data: postData,
							type: "POST",
							success: function(data){ 
								if(data.return == true){ 
									$("#dialog_edit_{$contract[contract][0]}").dialog("destroy");
									$("#contract").load('contract?do=list&page={$contract_page_curr}&get=table').hide().fadeIn("slow");
								}
								else{
									$('.progressbar').hide();
									content = data.return;
									$("#"+content+"_{$contract[contract][0]}").attr('class', 'input-error');
								}
							}
						});
					}).submit();
				});
				
				$('#niemphong_{$contract[contract][0]}').change(function(){
					if($(this).prop('checked')){
						$('#niemphong_hidden_{$contract[contract][0]}').remove();
					}
					else{
						$('#niemphong_{$contract[contract][0]}').after('<input id="niemphong_hidden_{$contract[contract][0]}" type="hidden" name="niemphong" value="0">');
					}
				});
				
				{section name=product loop=$product}
				{if $product[product][1] == $contract[contract][0]}
				$('#logo_{$contract[contract][0]}_{$product[product][0]}').change(function(){
					if($(this).prop('checked')){
						$('#logo_hidden_{$contract[contract][0]}_{$product[product][0]}').remove();
					}
					else{
						$('#logo_lbl_{$contract[contract][0]}_{$product[product][0]}').after('<input id="logo_hidden_{$contract[contract][0]}_{$product[product][0]}" type="hidden" name="logo[]" value="0">');
					}
				});
				$('#hoavan_{$contract[contract][0]}_{$product[product][0]}').change(function(){
					if($(this).prop('checked')){
						$('#hoavan_hidden_{$contract[contract][0]}_{$product[product][0]}').remove();
					}
					else{
						$('#hoavan_lbl_{$contract[contract][0]}_{$product[product][0]}').after('<input id="hoavan_hidden_{$contract[contract][0]}_{$product[product][0]}" type="hidden" name="hoavan[]" value="0">');
					}
				});
				$('#signed_{$contract[contract][0]}_{$product[product][0]}').change(function(){
					if($(this).prop('checked')){
						$('#signed_hidden_{$contract[contract][0]}_{$product[product][0]}').remove();
					}
					else{
						$('#signed_lbl_{$contract[contract][0]}_{$product[product][0]}').after('<input id="signed_hidden_{$contract[contract][0]}_{$product[product][0]}" type="hidden" name="signed[]" value="0">');
					}
				});
				$('#matma_{$contract[contract][0]}_{$product[product][0]}').change(function(){
					if($(this).prop('checked')){
						$('#matma_hidden_{$contract[contract][0]}_{$product[product][0]}').remove();
					}
					else{
						$('#matma_lbl_{$contract[contract][0]}_{$product[product][0]}').after('<input id="matma_hidden_{$contract[contract][0]}_{$product[product][0]}" type="hidden" name="matma[]" value="0">');
					}
				});
				{/if}
				{/section}
			{/section}
			
				$("select#contract_display").change(function(){
					var str = "";
					$("select#contract_display option:selected").each(function() {
						str = $( this ).text();
					});
					$.ajax({
						url: 'ajax?get=contract&do=display',
						data: 'number='+str,
						type: "POST",
						success: function(json) {
							$("#contract").load('contract?do=list&page={$contract_page_curr}&get=table').hide().fadeIn("slow");
						}
					});
				});
				$("input#search").keyup(function(e){
					if(e.keyCode == 13){
						var str = $(this).val();
						str = str.replace(/&/g, "%26");
						str = str.replace(/ /g, "%20");
						$.ajax({
							success: function(json) {
								var uri = 'contract?do=list&page={$contract_page_curr}&get=table&search='+str;
								$("#contract").load(uri).hide().fadeIn("slow");
							}
						});
					}
				});
		{/if}
		
		{if $menu == 'contract_add'}
				$( "#marketing" ).autocomplete({
				  source: [{section name=mk loop=$marketing}"{$marketing[mk]}",{/section} ]
				});
				var count_add = 1;
				$('#addmore').click(function(){
					count_add++;
					var clonedRow = '<td align="center"><b>'+count_add+'</b><br><br><a id="del_'+count_add+'" style="cursor:pointer">xóa</a></td><td align="left"><span class="inline">Sản phẩm: <input type="text" id="product_name_'+count_add+'" name="product_name[]" size="28" value="Hóa đơn GTGT"><select name="product_page[]">{for $foo=1 to 10}<option value="{$foo}" {if $foo == 3}selected{/if}>{$foo}</option>{/for}</select> liên</span><br><span class="inline">Mẫu số: <input id="form_'+count_add+'" type="text" name="form[]" size="13" onblur="javascript:{literal}{this.value = this.value.toUpperCase(); }{/literal}" value="01GTKT3/001"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="inline">Ký hiệu: <input id="serial_'+count_add+'" type="text" name="serial[]" size="13" onblur="javascript:{literal}{this.value = this.value.toUpperCase(); }{/literal}" value="AA/{$year}P"></span><br><span class="inline">Logo: <label id="logo_lbl_'+count_add+'"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="logo[]" id="logo_'+count_add+'" /> <span class="lbl"></span></label></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="inline">Hoa văn: <label id="hoavan_lbl_'+count_add+'"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="hoavan[]" id="hoavan_'+count_add+'" /> <span class="lbl"></span></label></span><br><span class="inline">Chống ký: <label id="signed_lbl_'+count_add+'"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="signed[]" id="signed_'+count_add+'" /> <span class="lbl"></span></label></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="inline">Mật mã: <label id="matma_lbl_'+count_add+'"><input class="ace ace-switch ace-switch-3" type="checkbox" value="1" name="matma[]" id="matma_'+count_add+'" /> <span class="lbl"></span></label></span></td><td align="left"><span class="inline">Số màu: <select name="color[]">{for $foo=1 to 10}<option value="{$foo}">{$foo}</option>{/for}</select></span><br><span class="inline">Ruột:<select name="bowel[]"><option value="baibang">Bãi Bằng</option><option value="cacbon" selected>Cacbon</option><option value="offset">Offset</option></select></span><br><span class="inline">Kích thước: <input type="text" name="size[]" size="10" value="210 x 297mm"></span></td><td align="center"><select name="unit[]"><option value="quyen50" selected>Quyển(50 số)</option><option value="quyen100">Quyển(100 số)</option><option value="so">Số</option><option value="thung">Thùng</option><option value="to">Tờ</option></select></td><td align="center"><input id="quantity_'+count_add+'" type="text" name="quantity[]" size="5" class="money" style="text-align:right"></td><td align="center"><input id="quantity_t_'+count_add+'" type="text" name="quantity_t[]" size="6" style="text-align:right"></td><td align="center"><input id="quantity_d_'+count_add+'" type="text" name="quantity_d[]" size="6" style="text-align:right"></td><td align="center"><input id="price_'+count_add+'" type="text" name="price[]" size="10" class="money" style="text-align:right"></td>';
					var appendRow = '<tr id="tr_'+count_add+'">' + clonedRow + '</tr>';
					$('#contract_addtable tr:last').after(appendRow);
					{for $foo=1 to 10}
					$('#del_{$foo}').click(function(){ 
						$('#tr_{$foo}').remove();
						count_add = 1;
					});
					{/for}
				});

				
				$('#date').datepicker({literal}{autoclose:true}{/literal}).next().on(ace.click_event, function(){
					$(this).prev().focus();
				});
								
			{if $error == 'tax'}
				alert('Mã số thuế không đúng!');
				$("#tax").attr("class", "input-error");
			{/if}
			{if $success}
				alert('Nhập thành công!');
			{/if}
		{/if}
		
		{if $menu == 'statistic'}
				$('#tktungay').datepicker({literal}{autoclose:true}{/literal}).next().on(ace.click_event, function(){
					$(this).focus();
				});
				$('#tkdenngay').datepicker({literal}{autoclose:true}{/literal}).next().on(ace.click_event, function(){
					$(this).focus();
				});
		{/if}

		{if $menu == 'cover_list'}
			{section name=cover loop=$cover}
				$("#cview_{$cover[cover][0]}").click(function(){
					$("#dialog_cview_{$cover[cover][0]}").dialog({literal}{width: '80%', modal: true}{/literal});
				});
			{/section}
			
				$("select#cover_display").change(function(){
					var str = "";
					$("select#cover_display option:selected").each(function() {
						str = $( this ).text();
					});
					$.ajax({
						url: 'ajax?get=cover&do=display',
						data: 'number='+str,
						type: "POST",
						success: function(json) {
							$("#cover").load('cover?do=list&page={$contract_page_curr}&get=table').hide().fadeIn("slow");
						}
					});
				});
				
				$("input#search").keyup(function(e){
					if(e.keyCode == 13){
						var str = $(this).val();
						str = str.replace(/&/g, "%26");
						str = str.replace(/ /g, "%20");
						$.ajax({
							success: function(json) {
								var uri = 'cover?do=list&page={$contract_page_curr}&get=table&search='+str;
								$("#cover").load(uri).hide().fadeIn("slow");
							}
						});
					}
				});

				{section name=cover loop=$cover}
				$("#close_{$cover[cover][0]}").click(function(){
					$("#dialog_cview_{$cover[cover][0]}").dialog("close");
				});
				{/section}
		{/if}

		})
		</script>
